export default {
	namespaced: true,
	state: () => ({
		addressList: [], //地址薄列表
		addressMood: {
			id: '',
			one: {
				addressType: 0,
				name: "",
				address: "",
				detail: "",
				contact: "",
				phone: "",
				lng: "",
				lat: "",
				addsort: ''
			},
			two: [],
			three: {
				addressType: 1,
				name: "",
				address: "",
				detail: "",
				contact: "",
				phone: "",
				lng: "",
				lat: "",
				addsort: ''
			},
			leibie: '',
			length: ''
		}

	}),
	mutations: {
		//修改地址薄
		getAddressList(state, data) {
			state.addressList = data
		},
		//根据下标
		update(state, data) {

			for (let k in data.mood) {
				state.addressMood.two[data.k][k] = data.mood[k]
			}
			uni.setStorageSync("Commonlyused", JSON.stringify(state.addressMood));

		},

		//修改添加常用地址
		modify(state, data) {
			for (let k in data) {
				state.addressMood[k] = data[k]
			}
			uni.setStorageSync("Commonlyused", JSON.stringify(state.addressMood));
			state.Commonlyused = JSON.parse(uni.getStorageSync("Commonlyused"))

		},
		//拿去常用路线
		acquire(state, data) {
			state.addressMood = data
			uni.setStorageSync("Commonlyused", JSON.stringify(state.addressMood));
			state.addressMood = JSON.parse(uni.getStorageSync("Commonlyused"))

		},
	},
	actions: {
		//获取地址薄地址
		async search_addr_book(context, data) {
			const {
				data: res
			} = await this.$http.address.search_addr_book(data)
			if (res.success) {
				context.commit('getAddressList', res.data)
			}
		}
	}
}